package so.ifl.commons.tools.xml;

import java.io.IOException;
import java.io.StringReader;
import java.util.HashMap;
import java.util.Map;

import javax.xml.parsers.ParserConfigurationException;
import javax.xml.parsers.SAXParserFactory;
import org.xml.sax.InputSource;
import org.xml.sax.SAXException;
import org.xml.sax.XMLReader;

/**
 *create by aaron.lu
 *create at 2012-3-18 上午11:15:49
 *<mailto: atyuan.lu@gmail.com>
 **/
public class XMLStringParser {
	
	
	static public Map<String, Object> parseXMLString(String xmlString) throws SAXException, ParserConfigurationException, IOException{
		
		Map<String, Object> rs = new HashMap<String, Object>();
		XMLReader xmlReader = SAXParserFactory.newInstance().newSAXParser().getXMLReader();
		XMLContentHandler contentHandler = new XMLContentHandler(rs);   
        xmlReader.setContentHandler(contentHandler);   
        xmlReader.parse(new InputSource(new StringReader(xmlString)));
		   
        return rs;
	}

}
